package com.adeoservices.gwt.dispatch.spring.sample.server.denied;

import net.customware.gwt.dispatch.server.ActionHandlerRegistry;
import net.customware.gwt.dispatch.server.ExecutionContext;
import net.customware.gwt.dispatch.shared.ActionException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.adeoservices.gwt.dispatch.spring.sample.client.denied.DeniedAction;
import com.adeoservices.gwt.dispatch.spring.sample.client.denied.DeniedResult;
import com.adeoservices.gwt.dispatch.spring.sample.server.business.MyBusinessService;
import com.adeoservices.gwt.dispatch.spring.server.handler.SpringActionHandler;
import com.adeoservices.gwt.dispatch.spring.server.security.Permission;

@Component
@Permission(verifier=DenyPermissionVerifier.class)
public class DeniedActionHandler extends SpringActionHandler<DeniedAction, DeniedResult>{

	@Autowired
	private MyBusinessService myBusinessService;

	@Autowired
	public DeniedActionHandler(ActionHandlerRegistry actionHandlerRegistry) {
		super(actionHandlerRegistry);
	}

	public DeniedResult execute(DeniedAction action, ExecutionContext context)
			throws ActionException {
		
		// should never be called
		myBusinessService.printHello();
		
		return new DeniedResult();
	}

	public Class<DeniedAction> getActionType() {
		return DeniedAction.class;
	}

	public void rollback(DeniedAction action, DeniedResult result,
			ExecutionContext context) throws ActionException {
	}

}
